
/*
 * CountEdgesReducer.java
 *
 * Created on May 7, 2012, 12:48:38 AM
 */

package CountEdges;


import java.io.IOException;
import java.util.Iterator;
// import org.apache.commons.logging.Log;
// import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.mapred.MapReduceBase;
import org.apache.hadoop.mapred.OutputCollector;
import org.apache.hadoop.mapred.Reducer;
import org.apache.hadoop.mapred.Reporter;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.LongWritable;

/**
 *
 * @author crazymooner
 */
public class CountEdgesReducer extends MapReduceBase implements Reducer<Text,LongWritable,Text,LongWritable> {
    // The Karmasphere Studio Workflow Log displays logging from Apache Commons Logging, for example:
    // private static final Log LOG = LogFactory.getLog("CountEdges.CountEdgesReducer");

	@Override
    public void reduce(Text key, Iterator<LongWritable> value, OutputCollector<Text, LongWritable> output, Reporter reporter)
            throws IOException {
		 int sum = 0;
		 while (value.hasNext()){
			 sum += value.next().get();
		 }
		 output.collect(new Text ("Edges: "), new LongWritable(sum)); 
    }
}
